var arr = [8888, 1, 2, 3, 4, 5, 999, 6, 10, 9, 8, 7, 15];
let max = arr[0];//假设数组第一位为最大值
let max2 = arr[1];//假设数组第二位为第二大值
if (arr[0] >= arr[1]) {
    [max, max2] = [arr[0], arr[1]];//ES6语法：解构赋值
} else {
    [max2, max] = [arr[0], arr[1]];
}
for (let i = 2; i < arr.length; i++) {
    if (arr[i] > max2) {
        if (arr[i] > max) {
            max2 = max;
            max = arr[i];
        } else {
            max2 = arr[i];
        }
    }
}
console.log(max);
console.log(max2, arr.indexOf(max2));
